<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<c:set var="grantCode"><x:out select="$xmlData/data/proposal/grant_code" /></c:set>
 <input type="hidden" name="organizations/organization[0]/sequence_no" value="1" >
<input type="hidden" name="organizations/organization[0]@submit_org" value="1" >
<input type="hidden" name="organizations/organization[0]/org_code" value="<x:out select="$xmlData/data/organizations/organization[@submit_org=1]/org_code"/>" >

<div class="t_bar">申请单位基本情况</div>
<table class="t_css" width="100%" border="0" cellpadding="0"
	id="orgInfo1" cellspacing="1">
	<col width="15%"/>
	<col width="35%"/>
	<col width="20%"/>
	<col width="30%"/>
	<tr>
		<td align="right" nowrap>依托单位名称：</td>
		<td colspan="3">&nbsp;<span name="organizations/organization[0]/org_name"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/org_name" />
		    </span>
		</td>
	</tr>
	<tr>
		<td align="right" nowrap><span class="color_red">*</span>归口管理部门：</td>
		<td colspan="3">
			<c:set var="recomend_org"><x:out select="$xmlData/data/proposal/recomend_org_value" /></c:set>
			<c:set var="sqOrgCode"><x:out select="$xmlData/data/organizations/organization[@submit_org=1]/org_code"/></c:set>
			<cpt:select id="recomend_org" sqlParamVal="{currentorgcode:${sqOrgCode }}"  key="proposal_tjbm"  value="${recomend_org}" onChange="initControlValue(this.id);" style="width:200px;"></cpt:select>
			<input type="hidden" id="recomend_org_value" name="proposal/recomend_org_value" class="required" value="${recomend_org}" label="归口管理部门">
			<input type="hidden" name="proposal/recomend_org_name" value="<x:out select="$xmlData/data/proposal/recomend_org_name" />">
		</td>
	</tr>
	<tr>
		<td align="right">单位地址：</td>
		<td >&nbsp;
		    <span name="organizations/organization[0]/address"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/address" /></span>
		</td>
		<td align="right" >邮政编码：</td>
		<td >&nbsp;
		    <span name="organizations/organization[0]/zip_code"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/zip_code" /></span>
		</td> 
	</tr>
	<tr>
		<td align="right" rowspan="2">法定代表人：</td>
		<td rowspan="2">&nbsp;
		    <span name="organizations/organization[0]/faren_name"> 
			    <x:out select="$xmlData/data/organizations/organization[@submit_org='1']/faren_name" />
		    </span>
		</td>
		<td align="right">固定电话：</td>
		<td>&nbsp; 
		     <span name="organizations/organization[0]/faren_tel"> 
			    <x:out select="$xmlData/data/organizations/organization[@submit_org='1']/faren_tel" />
		    </span>
		</td>
	</tr>
	<tr>
		<td align="right" class="li_2">移动电话：</td>
		<td class="li_2">&nbsp;
		    <span name="organizations/organization[0]/faren_mobile"> 
			    <x:out select="$xmlData/data/organizations/organization[@submit_org='1']/faren_mobile" />
		    </span>
		</td>
	</tr>
	<tr>
		<td align="right" class="li_1">职工总数：</td>
		<td class="li_1">&nbsp;
			<span name="organizations/organization[0]/people_count_total"> 
			    <x:out select="$xmlData/data/organizations/organization[@submit_org='1']/people_count_total" />人
		    </span>
		</td>
		<td align="right" class="li_1" >其中：高中级职称人数：</td>
		<td class="li_1">&nbsp;
			<c:set var="pth"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/prof_title_high" /></c:set>
			<c:set var="ptm"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/prof_title_middle" /></c:set>
			<span name="organizations/organization[0]/prof_title_high">${pth+ptm }人</span>
		</td> 
	</tr>
	<tr class="li_2">
		<td align="right">注册类型：</td>
		<td colspan="3">&nbsp;
		   <span name="organizations/organization[0]/nature_name"> 
			    <x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_name" /> 
		    </span>
		    <input type="hidden" name="organizations/organization[0]/nature_value"  value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />"/>
		</td>
	</tr>
</table>

<table class="t_css" width="100%" border="0" cellpadding="0"
	id="orgInfo2" cellspacing="1">
	<col width="15%"/>
	<col width="10%"/>
	<col width="25%"/>
	<col width="20%"/>
	<col width="30%"/>
	<tr>
		<td align="right" rowspan="4">拟配备工程中心主任：</td>
		<td  align="right"><span class="color_red"></span>姓名：</td>
		<td  >
			<span name="proposal/pesn/personname"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/zh_name" /></span>
		</td>
		<td  align="right"><span class="color_red"></span>职称/职务：</td>
		<td >
		<span name="proposal/pesn/position"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/prof_title_name" />/<x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/position" /></span>
		</td>
	</tr>
	<tr>
		<td  align="right"><span class="color_red"></span>工作单位：</td>
		<td  >
			<span name="proposal/pesn/work_orgname"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/org_name" /></span>
		</td>
		<td  align="right"><span class="color_red"></span>出生日期：</td>
		<td  >
				<span name="proposal/pesn/birthday"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/birthday" /></span>
		</td>
	</tr>
	<tr>
		<td  align="right"><span class="color_red"></span>固定电话：</td>
		<td  >
				<span name="proposal/pesn/tel_wrok"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/tel_work" /></span>
		</td>
		<td  align="right"><span class="color_red"></span>传   真：</td>
		<td  >
				<c:set var="psn_fax"><x:out select="$xmlData/data/proposal/pesn/fax" /></c:set>
				<c:if test="${empty psn_fax }"><c:set var="psn_fax"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/fax" /></c:set></c:if>
				<input type="text" name="proposal/pesn/fax" maxlength="20" label="拟配备工程中心主任-->传真" value="${psn_fax }" />
		</td>
	</tr>
		<tr>
		<td  align="right"><span class="color_red"></span>移动电话：</td>
		<td  >
				<span name="proposal/pesn/mobile"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/mobile" /></span>
		</td>
		<td  align="right"><span class="color_red"></span>E-mail：</td>
		<td  >
				<span name="proposal/pesn/email"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/contact/email" /></span>
		</td>
	</tr>
	<tr>
		<td align="right" rowspan="2"><span class="color_red">*</span>工程中心联系人：</td>
		<td colspan="2" rowspan="2">
			<input name="proposal/gczxlxr/personname" label="工程中心联系人" type="text" required class="input_text required "   maxlength="20" value="<x:out select="$xmlData/data/proposal/gczxlxr/personname" />"/>
		</td>
		<td  align="right"><span class="color_red">*</span>固定电话：</td>
		<td >
		<input name="proposal/gczxlxr/tel_work" label="固定电话" type="text" required class="input_text required "   maxlength="20" value="<x:out select="$xmlData/data/proposal/gczxlxr/tel_work" />"/>
		</td>
	</tr>
	<tr>
		<td  align="right"><span class="color_red">*</span>移动电话：</td>
		<td >
		<input name="proposal/gczxlxr/mobile" label="移动电话" type="text" required class="input_text required mobile" onfocus="InitInput.setNumber(this,11,0,0)"  maxlength="11" value="<x:out select="$xmlData/data/proposal/gczxlxr/mobile" />"/>
		</td>
	</tr>
</table>


<div class="t_bar">
<span class="color_red">*</span>共建单位（至少一家）
</div>
		<table  id="heisi_wangkun" cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;table-layout: fixed;" >
			<col width="7%" />
			<col width="8%" />
			<col width="85%" />
			<thead >
					<tr style="border:1px solid #B7D1E6">
						<th class="TblHead" align="center" >选择</th>
						<th class="TblHead" align="center" >序号</th>
						<th class="TblHead" align="center" >单位名称</th> 
					</tr>
			</thead>
			<tbody id="tab">
					<tr style="display:none" align="center">
						<td align="center">
							<input type="radio" class="radiobutton" name="heisi_wangkun" >
						</td>
						<td align="center">
							<span name="heisi_wangkun|list[0]@seq_no" >[index]</span> 
						</td>
						<td align="center">
							<input type="text" name="heisi_wangkun|list[0]|content" label="单位名称" class=" required input_text " maxlength="50" style="width:80%"/>
						</td>
					</tr>
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/heisi_wangkun/list" var="list">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr align="center">
						<td align="center">
							<input type="radio" class="radiobutton" name="heisi_wangkun" >
						</td>
						<td align="center">
							<span name="heisi_wangkun/list[${flag}${index}]@seq_no" ><x:out select="$list/@seq_no"/></span> 
						</td>
						<td align="center">
							<input type="text" name="heisi_wangkun/list[${flag}${index}]/content"  value="<x:out select="$list/content"/>"   label="单位名称" class=" required input_text " maxlength="50" style="width:80%"/>
						</td>
					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					</x:forEach>
					<script type="text/javascript">
						showAllDateTag("heisi_wangkun");
					</script>
				</tbody>
				</table>
		<table width="98%" align="center" border="0">
					<tr style="border: 0"><td style="border: 0">
					<input class="button" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('heisi_wangkun',99,'共建单位最多只能添加99条')){addNewRow('heisi_wangkun');showDateTag('heisi_wangkun');try{top.resizeFrame();}catch(e){};}">
					<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev3('heisi_wangkun','heisi_wangkun')">
					<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext3('heisi_wangkun','heisi_wangkun')">
					<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow3('heisi_wangkun','共建单位');">
					</td></tr>
	</table>	
		
<script type="text/javascript">
	
	/**
	 * 上移行
	 * @param tblId
	 * @returns {Boolean}
	 */
	function movePrev3(tblId,selName) {
		if (!selName)
			selName = "";
		if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
			scmWarn(irisNotes.prevWarn);
			return false;
		}
		if ($("#" + tblId + " tr").length <= 2)
			return false;
		var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
				.parents("tr").first();// 取得被选中的行
		var trPrev = trChecked.prev();// 取得上一行
		var index = trChecked.get(0).rowIndex;// 获得行号
		if (index <= 2) {// 如果是第一行
			scmWarn(irisNotes.tabelMoveWarn1);
			return false;
		}
		//trChecked.remove();
		trPrev.before(trChecked);
		trChecked.find(":radio[name*='" + selName + "']").attr("checked", 'true');
		refreshRowINdex33(tblId);
	}

	/**
	 * 下移行
	 * @param tblId
	 * @returns {Boolean}
	 */
	function moveNext3(tblId,selName) {
		if (!selName)
			selName = "";
		if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
			scmWarn(irisNotes.nextWarn);
			return false;
		}
		if ($("#" + tblId + " tr").length <= 2) {
			return false;
		}
		var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
				.parents("tr").first();// 取得被选中的行
		var trNext = trChecked.next();
		var index = trChecked.get(0).rowIndex;// 获得行号
		if (index == $("#" + tblId + " tr").length - 1) {// 如果是第一行
			scmWarn(irisNotes.tabelMoveWarn2);
			return false;
		}
		//trChecked.remove();
		trNext.after(trChecked);
		trChecked.find(":radio[name*='" + selName + "']").attr("checked", "true");
		refreshRowINdex33(tblId);
	}

	/**
	 * 重新计算行号
	 * @param tblId
	 */
	function refreshRowINdex33(tblId){
		 //重新计算行号
		  $("#"+tblId+" tr").each(function(){
			   var seq=$(this).get(0).rowIndex;//获得行数
			   if(seq>1){//如果有行  显示时display行不计入类，故只减1
				   seq=seq-1;
				   var seq_no=$(this).find("[name$='seq_no']");
				   if(seq_no.is("span"))
					   seq_no.html(seq);
				   else
					   seq_no.val(seq);
				   
				   seq=""+(seq-1);
				   if(seq.length==1)
					   seq="0"+seq;
				  //替换相应的name参数的seq
				  $(this).find("input,span,textarea,select").each(function(){
					   var name=$(this).attr("name");
					   if(name!=null&&name!=""){
						   name=name.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("name",name);
					   }
					   var id=$(this).attr("id");
					   if(id!=null&&id!=""){
						   id=id.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("id",id);
						   id=id.replace(/\d+/g,""+seq+"");
						   $(this).attr("id",id);
					   }
					   var className=$(this).attr("class");
					   if(className!=null&&className!=""){
						   className=className.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("class",className);
					   }
				   });
			   }
			 }
		  );

	}
	
	
	/**
	 * 删除一行
	 * @param radioId 
	 */
	function deleteSelectedRow3(tableId,message,nummin,warnMsg,selName){
		if(!selName)selName="";
		var tr=$("#"+tableId+" :radio[name*='"+selName+"']:checked").parents("tr");
		if(nummin==null)
			nummin=0;
		var length=tr.length;
		if(tr.length==0)
			tr=$("#"+tableId+" tr").filter(":last");
		else if(tr.length>1)
			tr=tr.first();

		if(tr.get(0).rowIndex-1==nummin){
			scmWarn(irisNotes.delWarn1);
			return false;
		}
		if(length==0){
			
				scmWarn(irisNotes.delWarn2);
			
			return false;
		}
		  if(!confirm(messageTip.deleteTip+message+"？"))
			  return false;
		  tr.remove();
		  refreshRowINdex33(tableId);
		  return true;
		  setSubmitOrg() ;
	}
	</script>
	
